#ifndef MYHANDLER_H
#define MYHANDLER_H

#include "Buffer.h"
#include "parser.h"

class MyHandler
{
public:
    MyHandler(const int connfd);
    ~MyHandler();

    void handle();
    const int connFd() const
    {
        return _connfd;
    }

private:
    int _connfd;

    bool receiveRequest();  // 接受客户的请求并解析
    void sendResponse();    // 发送相应
    void sendErrorMsg(const std::string &errorNum,
                      const std::string &shortMsg,
                      const std::string &longMsg);
    void parseURI();
    void getFileType();

    bool _isClosed;
    std::string _fileType;
    std::string _fileName;
    Buffer _inputBuffer;
    Buffer _outputBuffer;
    HTTPRequest _request;
};

#endif // MYHANDLER_H
